package dome3;

import java.util.Scanner;

public class Day0101 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int count = 0;
        for(int i=a;i<=b;i++) {
            count += sumCount(i);
        }
        System.out.println(count);
    }

    private static int sumCount(int num ) {
        int count = 0;
        while(num > 0) {
            if(num%10 == 2) count++;
            num /= 10;
        }
        return count;
    }

//    public static void main(String[] args) {
//        Scanner in = new Scanner(System.in);
//        int a = in.nextInt();
//        int b = in.nextInt();
//        int count = 0;
//        for(int i=a;i<=b;i++) {
//            count += sumCount(i);
//        }
//        System.out.println(count);
//    }
//
//    private static int sumCount(int num ) {
//        if(num == 0) return 0;
//        if(num%10 == 2) return 1;
//        return
//    }
}
